<template>
    <div>
        <div class="now">
            <p>
                可提现余额
            </p>
            <span>
                ￥{{userInfo.accountBalance}}
            </span>
        </div>
        <div class="box">
            <div class="box_top">
                <!-- <h5>请输入提现金额</h5> -->
                <span class="dl">￥</span>
                <input type="text" placeholder="请输入提现的金额" maxlength="9" v-model="postUo.balance" onkeyup="this.value= this.value.match(/\d+(\.\d{0,1})?/) ? this.value.match(/\d+(\.\d{0,1})?/)[0] : ''" onblur='this.value=this.value.replace(/^[0]+[0-9]*$/gi,"")'>
                <button class="btn" @click="getCash()">确认</button>
            </div>
            <div class="box_bottom">
                <p>说明：</p>
                <p>1、用户可随时进行提现操作，我们将在1-3个工作日内打款到您认证的银联账户上，请您注意关注银联账户信息</p>
                <p>2、目前只提供单笔提现操作，如需进行多次提现操作，需完结本次操作后，再进行下一笔提现操作</p>
                <p>3、提现金额需为100元及以上，单次提现手续费为2元</p>
                <p>4、如有问题，请致电联系，客服电话：400-666-6688</p>
            </div>
        </div>
    </div>
</template>

<script>
import http from "@/assets/js/axios";
import { domain } from '@/assets/js/config'
import $ from 'jquery'
import { maskTips } from '@/assets/js/dom'
export default {
    data() {
        return {
            userInfo: '',
            userToken: '',
            postUo: {
                balance: ''
            }
        }
    },
    components: {

    },
    mounted() {
        let userToken = localStorage.getItem("token") || ''
        this.userToken = userToken
        this.getReason();
    },
    methods: {
        direct: function (val) {
            this.$router.push({ path: '/' + val });
        },
        // 用户信息
        getReason: async function () {
            const res = await http.post('xshk/f/assets/query?token=' + this.userToken)
            if (res.data.code == -5) {
                maskTips({ id: "bal-fail", txt: res.data.message })
                this.$router.push('/login')
                return false;
            }
            if (res.data.code == 0) {
                this.userInfo = res.data.data
            }
        },

        // 提现
        getCash: async function () {
            if (this.userInfo.accountBalance == 0) {
                maskTips({ id: "ye-success", txt: '当前没有余额可提现' })
                return false;
            }
            const res = await http.post('xshk/f/assets/balanceby?token=' + this.userToken, this.postUo)
            if (res.data.code == 0) {
                maskTips({ id: "cash-success", txt: res.data.message })
                setTimeout(function () {
                    window.location.reload();
                }, 1000);
            } else {
                maskTips({ id: "cash-fail", txt: res.data.message })

            }
        }

    }
}
</script>

<style  scoped>
/*可提现余额*/
.now {
    width: 88.5%;
    height: 3rem;
    text-align: center;
    color: #fff;
    position: relative;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    margin: 0.4rem auto 0;
    background: #aad114;
    box-sizing: border-box;
    padding: 0.78rem 0;
}

.now p {
    font-size: 0.4rem;
    color: #ddffe8;
    font-family: "MicrosoftYaHei";
}
.now span {
    font-size: 0.6rem;
    font-weight: 900;
    font-family: "MicrosoftYaHei-Bold";
}

.box {
    padding: 0 0.48rem;
    box-sizing: border-box;
}
.box .box_top h5 {
    margin-top: 0.4rem;
    font-size: 0.3rem;
    font-weight: 500;
    color: #3b3b3b;
    font-family: "PingFang-SC-Medium";
}
.box .box_top input {
    box-sizing: border-box;
    width: 100%;
    height: 1rem;
    float: left;
    border: none;
    outline: none;
    font-size: 0.45rem;
    line-height: 0.6rem;
    font-weight: 600;
    border-bottom: 1px solid #f5f5f5;
    margin: 0 auto 0.48rem;
    font-family: "PingFang-SC-Heavy";
    position: relative;
    padding: 0 0.6rem;
}
.dl {
    position: absolute;
    display: inline-block;
    height: 1rem;
    z-index: 9;
    font-family: "PingFang-SC-Heavy";
    font-size: 0.6rem;
    line-height: 0.6rem;
    font-weight: 600;
    padding-top: 10px;
}
::-webkit-input-placeholder {
    /* WebKit browsers */
    color: #999;
    font-size: 0.45rem;
    line-height: 0.6rem;
    text-align: left;
    font-weight: 600;
    font-family: "PingFang-SC-Heavy";
}
.box .box_top .btn {
    float: left;
    width: 100%;
    height: 0.96rem;
    border: none;
    outline: none;
    background: #aad114;
    border-radius: 5px;
    color: #fff;
    margin-bottom: 0.4rem;
    font-size: 0.37rem;
}
.box .box_bottom {
    font-size: 0.24rem;
    color: #999;
    font-family: "PingFang-SC-Regular";
}
.box .box_bottom p {
    line-height: 0.48rem;
    font-family: "PingFang SC";
}
</style>
